package com.example.hp.storeapp.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.hp.storeapp.Activity.CookDetailActivity;
import com.example.hp.storeapp.R;
import com.example.hp.storeapp.bean.CookResult;
import com.example.hp.storeapp.fragment.ViewHolder.CookListViewHolder;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by NEUSOFT on 2017/5/8.
 */

public class ShopDetailAdapter extends BaseAdapter {

    public ShopDetailAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {

        View itemView = layoutInflater.inflate(R.layout.item_food_list, parent,false);
        CookListViewHolder viewHolder = new CookListViewHolder(itemView);
        return viewHolder;
    }

    @Override
    void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {

        final CookResult cook = (CookResult) data.get(position);
        CookListViewHolder viewHolder = (CookListViewHolder) holder;

        String foodName = cook.getFoodname();
        int price = cook.getPrice();
        final int foodId = cook.getShop_id();
        int shopId = cook.getShop_id();

        String pic = cook.getPic();
        if (!pic.equals("")){
//            imageUrl = " http://172.24.10.130:8080/foodService/"+shopResult.getPic();
            Picasso.with(context).load(pic).into(CookListViewHolder.imageViews);

            viewHolder.foodNameView.setText(foodName);
            viewHolder.foodPriceView.setText(String.valueOf(price));
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //启动菜品详情Activity
                    Intent intent = new Intent(context, CookDetailActivity.class);
                    //intent.putExtra("cook",cook);
                    intent.putExtra("food_id",cook.getFood_id());
                    context.startActivity(intent);


                }
            } );

        }

       // shopItemViewHolder.textView_Level.setText(String.valueOf(level));





    }
}
